﻿<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta http-equiv="Pragma" content="no-cache" />
    <meta http-equiv="Cache-Control" content="no-cache" />
    <meta http-equiv="Expires" content="0" />
    <!-- 上述3个meta标签*必须*放在最前面，任何其他内容都*必须*跟随其后！ -->
    <title>企业公告</title>
    <link href="/CSS/bootstrap3.3.5/css/bootstrap.css" rel="stylesheet" type="text/css" />
    <link href="/CSS/Base/BaseClass.css?cssver=4" rel="stylesheet" type="text/css" />
    <script src="/Scripts/jquery-1.11.2.min.js"></script>
    <script src="/JqueryPlug/laypage/laypage.js"></script>
    <script src="/Scripts/avalon.js"></script>
    <script src="/Scripts/jquery-migrate-1.1.0.min.js"></script>
    <script src="/Scripts/SZHLCommon.js?jsver=5"></script>
    <script>
        var model = avalon.define({
            $id: "CommonData",
            username: ComFunJS.getnowuser(),
            selGGType: "",
            curGGType: "",
            selSearContent: "",
            GGTypeData: [],
            CommonData: [],
            SearchContent: "",
            page: 0,
            totalCount: "",
            ReadUserList: [],
            completegg: function (action) {
                if (action == "add") {
                    if ($(".hidPan").length > 0) {
                        $(".hidPan").parent().find(".panel-body,.panel-footer").css("display", "none");
                        $(".hidPan")[0].click();
                    }
                }
            },
            AddQYGG: function () {
                parent.ComFunJS.winviewform("/View/APPBaseView/APP_ADD_WF.html?FormCode=QYGG", "添加数据", "1000", "");
            },
            GetGGDataList: function () {
                $.getJSON('/API/FTAPI.ashx?Action=GETUSERQYGGLIST', { P1: model.curGGType, P2: 1, content: model.SearchContent }, function (resultData) {
                    if (resultData.ErrorMsg == "") {
                        if (!model.totalCount) {
                            model.totalCount = resultData.Result1 == 0 ? "" : resultData.Result1;
                        }
                        model.CommonData = resultData.Result;
                        model.selGGType = model.curGGType;
                        model.selSearContent = model.SearchContent;
                        if (model.totalCount>8) {
                            laypage({
                                cont: 'pageDiv', //容器。值支持id名、原生dom对象，jquery对象。
                                pages: Math.ceil(parseInt(resultData.Result1) * 1.0 / 8), //通过后台拿到的总页数
                                curr: 1, //初始化当前页
                                jump: function (e) { //触发分页后的回调
                                    if (model.selGGType != model.curGGType || model.selSearContent != model.SearchContent) {
                                        e.curr = 1;
                                    }
                                    if (e.curr != 1) {
                                        $.getJSON('/API/FTAPI.ashx?Action=GETUSERQYGGLIST', { P1: model.curGGType, P2: e.curr, content: model.SearchContent }, function (resultData) {
                                            model.CommonData = resultData.Result;
                                            model.selGGType = model.curGGType;
                                            model.selSearContent = model.SearchContent;
                                        })
                                    }
                                }
                            });

                        }
                    }
                })

            },
            DELQYGG: function (Id, rowNumber) {
                if (confirm("确定要删除么？")) {
                    $.post("/API/FTAPI.ashx", { Action: "DELQYGGBYID", P1: Id }, function (result) {
                        var jsonresult = $.parseJSON(result)
                        if ($.trim(jsonresult.ErrorMsg) != "") {
                            ComFunJS.winwarning(jsonresult.ErrorMsg);
                        } else {
                            model.CommonData.remove(model.CommonData[rowNumber]);
                            parent.ComFunJS.winsuccess("删除成功");
                        }
                    })
                }
            }, EDITQYGG: function (ID) {
                parent.ComFunJS.winviewform("/View/APPBaseView/APP_ADD_WF.html?FormCode=QYGG&FrameName=frameQYGG&ID=" + ID, "修改数据", "1000", "");
            },
            UpdateRead: function (item) {
                $.post('/API/FTAPI.ashx?Action=UPDATEQYGGREADUSER', { "P1": item.ID }, function (result) {
                    var result = $.parseJSON(result);
                    if (!result.ErrorMsg == "") {
                        parent.ComFunJS.winwarning(result.ErrorMsg);
                    }
                })
            },
            AddPL: function (item, dom) {
                var plcontent = dom.val();
                if ($.trim(plcontent) == "") {
                    parent.ComFunJS.winwarning("请输入批注内容");
                    return;
                }
                $.post('/API/FTAPI.ashx?Action=ADDCOMENT', { "P1": plcontent, "MsgType": "QYGG", "MsgLYID": item.ID }, function (result) {
                    var result = $.parseJSON(result);
                    if (result.ErrorMsg == "") {
                        item.PLList.push(result.Result);
                        dom.val("")
                    }
                })
            },
            jptj: function (event, item, dom) {
                if (event.ctrlKey && (event.keyCode == 13 || event.keyCode == 10)) {
                    model.AddPL(item, dom);
                }
            }

        });
        avalon.ready(function () {
            ComFunJS.initsetajax();
            //获取主要菜单
            $.getJSON('/API/FTAPI.ashx?Action=GETCOLUMNLIST', { P1: "6" }, function (resultData) {
                if (resultData.ErrorMsg == "") {
                    model.GGTypeData = resultData.Result;
                }
            })

            model.GetGGDataList();
            $(".hidPan").live('click', function () {
                $(this).parent().find(".panel-body,.panel-footer").toggle('normal')
            })

        })
    </script>
</head>
<body ms-controller="CommonData">
    <div class="container-fluid maindiv" style="margin-top: 20px" id="dvContent">
        <div style="width:120px;position:absolute">
            <ul class="list-group text-center  leftmenu ">
                <li class="list-group-item sel">
                    <div>
                        <i class="iconfont hvr-grow">&#xe608;</i>
                        {{totalCount}}
                    </div>
                    <div>企业公告</div>
                </li>
            </ul>
        </div>
        <div class="row contentdv" style="margin-left:121px">
            <div class="col-xs-12 ">
                <div class="panel panel-default">
                    <div class="panel-body">
                        <div class="row">
                            <div class="col-xs-9">
                                <div class="input-group">
                                    <div class="input-group-addon">查询条件</div>
                                    <select class="form-control" ms-duplex="curGGType" style="width:30%" ms-change="GetGGDataList()">
                                        <option value="">全部公告类型</option>
                                        <option ms-attr-val="item.TypeNO" ms-repeat-item="GGTypeData">{{item.TypeNO}}</option>
                                    </select>
                                    <input id="tbSearch" class="form-control" type="text" style="width:70%" ms-duplex="SearchContent" placeholder="输入标题查询" />
                                    <span class="input-group-btn">
                                        <button class="btn btn-info" ms-click="GetGGDataList()">查询</button>
                                    </span>
                                </div>
                            </div>
                            <div class="col-xs-3 text-right">
                                <a href="#" ms-click="AddQYGG()" id="btADD" class="button  button-primary">添加公告</a>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="panel panel-default " ms-repeat-item="CommonData" data-repeat-rendered="completegg">
                    <span class="label label-info deldata" ms-click="EDITQYGG(item.ID)" style="right:50px;" ms-if="item.CRUser==username">修改</span>
                    <span class="label label-danger deldata" ms-click="DELQYGG(item.ID,$index)" ms-if="item.CRUser==username">删除</span>
                    <div class="panel-heading hidPan" ms-click="UpdateRead(item)" style="BACKGROUND-COLOR: WHITE;border-bottom: 0;">
                        <span class="panel-title">
                            &nbsp;[<strong>{{item.remark}}</strong>]{{item.GGTitle}}<span class="label label-danger" style="border-radius: 25PX;" ms-if="ComFunJS.daysBetween(ComFunJS.getnowdate('yyyy-mm-dd'), item.CRDate.substring(0,10)) == 0||ComFunJS.daysBetween(ComFunJS.getnowdate('yyyy-mm-dd'), item.CRDate.substring(0,10)) == -1">新!</span> <span class="pull-right">[{{item.FBTime|date("yyyy-MM-dd")}}by{{item.CRUserName}}]</span> <!--ms-if-->
                        </span>
                    </div>
                    <div class="panel-body">
                        <div ms-html="item.GGContent">
                        </div>
                        <label ms-if="item.FileList.length>0"> 附件：</label><a style="margin-left:10px" ms-repeat-files="item.FileList" target="_blank" download="filename" ms-attr-href="'/View/Common/DownLoadFile.aspx?MD5='+files.FileMD5">{{files.Name+'.'+files.FileExtendName}}</a>
                    </div>
                    <div class="panel-footer" style="overflow: hidden;border-top: 0;">
                        <ul class="nav nav-tabs" role="tablist">
                            <li role="presentation" class="active"><a ms-href="'#PLDiv'+item.ID" aria-controls="home" role="tab" data-toggle="tab">讨论区</a></li>
                            <li role="presentation"><a ms-href="'#ReadInfoDiv'+item.ID" aria-controls="home" role="tab" data-toggle="tab">已阅数<span class="badge" ms-if="item.ReadUser.split(',').length>0">{{item.ReadUser.split(',').length}}</span></a></li>
                        </ul>
                        <div class="tab-content">
                            <div ms-attr-id="'PLDiv'+item.ID" class="tab-pane active">
                                <div class="chat-widget" style="margin-top: 10PX; margin-bottom: 10px">
                                    <ul class="list-unstyled">
                                        <li class="by-me Yan-comment" ms-repeat-el="item.PLList">
                                            <div class="avatar" style="float: left">
                                                <img alt="" ms-attr-src="'/Upload/TX/'+el.CRUser+'.jpg'" style="width:65px;height:65px" onerror="javascript: this.src = '/images/TX/default.png'">
                                            </div>
                                            <div class="chat-content">
                                                <div class="chat-meta">{{el.CRUserName}} <span style="float: right"><!--ms-if--> {{el.CRDate|date("MM月dd日 HH:mm")}}</span></div>
                                                {{el.MSGContent}}
                                                <div class="clearfix"></div>
                                            </div>
                                        </li>
                                    </ul>
                                </div>
                                <div class="input-group">
                                    <input class="form-control" type="text" ms-keypress="jptj(event,item,$(this))" placeholder="此处添加批注(按Ctrl+Enter直接提交)" />
                                    <span class="input-group-btn">
                                        <button type="button" data-loading-text="正在保存..." class="btn  btn-info addTL" autocomplete="off" ms-on-click="AddPL(item,$(this).parent().parent().find('input'))">
                                            添加批注
                                        </button>
                                    </span>
                                </div>
                            </div>
                            <div class="tab-pane" ms-attr-id="'ReadInfoDiv'+item.ID" style="margin-bottom:10px">
                                <div class="pCard" ms-repeat-el="item.ReadUser.split(',')" style="min-width: 80px;text-align: center;">
                                    <div class="pName">{{ComFunJS.convertuser(el)}}</div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
                <div id="pageDiv" class="text-center"></div>
            </div>
        </div>
    </div>
    <script src="/CSS/bootstrap3.3.5/js/bootstrap.js" type="text/javascript"></script>
    <script src="/Scripts/SZHLCommon.js?jsver=5"></script>
</body>
</html>
